<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>图书管理</title>
    <meta name="decorator" content="default"/>
    <script src="${ctxStatic}/lodop/LodopFuncs.js" type="text/javascript"></script>
    <script type="text/javascript">
        function page(n, s) {
            $("#pageNo").val(n);
            $("#pageSize").val(s);
            $("#searchForm").submit();
            return false;
        }
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li><a href="${ctx}/book/purchase/list">采购批次</a></li>
    <li class="active"><a href="${ctx}/book/purchase/batch?batchId=${bkPurchaseBatch.batchId}">批次详情</a></li>
</ul>
<br/>
<form:form id="searchForm" modelAttribute="bkPurchaseBatch" action="${ctx}/book/purchase/batch" method="post"
           class="form-horizontal">
    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
    <div class="control-group">
        <label class="control-label">批次号:</label>

        <div class="controls">
           <input type="hidden" name="batchId" value="${bkPurchaseBatch.batchId}">
            <label>${bkPurchaseBatch.batchNumber}</label>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">登记时间:</label>

        <div class="controls">
            <fmt:formatDate value="${bkPurchaseBatch.batchDate}" pattern="yyyy-MM-dd"/>
        </div>
    </div>
    <%--<div class="control-group">--%>
        <%--<label class="control-label">码洋:</label>--%>

        <%--<div class="controls">--%>
            <%--<label>${bkPurchaseBatch.fixedPrice}</label>--%>
        <%--</div>--%>
    <%--</div>--%>
    <%--<div class="control-group">--%>
        <%--<label class="control-label">实洋:</label>--%>

        <%--<div class="controls">--%>
            <%--<label>${bkPurchaseBatch.discountedPrice}</label>--%>
        <%--</div>--%>
    <%--</div>--%>
    <div class="control-group">
        <label class="control-label">备注：</label>

        <div class="controls">
            <script>document.write(decodeURI('${bkPurchaseBatch.remarks}'))</script>
        </div>
    </div>
</form:form>

<table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead>
    <tr>
        <th width="20">序号</th>
        <th>ISBN</th>
        <th>书名</th>
        <th>分类号</th>
        <th>出版社</th>
        <th>出版日期</th>
        <th>整套价格</th>
        <%--<th>实际价格</th>--%>
        <%--<th>采购量</th>--%>
        <th>套数</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody id="details">
    <c:forEach items="${page.list}" var="info" varStatus="status">
        <tr>
            <td>${status.count}</td>
            <td>${info.bkIsbn}</td>
            <td>${info.bkName}</td>
            <td>${info.bkClass}</td>
            <td>${info.publisher}</td>
            <td>${info.pubdate}</td>
            <%--<td>${info.bkPrice}</td>--%>
            <td>${info.discountedPrice}</td>
            <%--<td>${info.mxCnt}</td>--%>
            <td>${info.mxArrived}</td>
            <td width='100'>
                <a href="javascript:printTagByDetails('${info.batchId}', '${info.bkId}','${info.pbdId}')">书标打印</a>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="pagination">${page}</div>


<object id="LODOP" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
    <param name="Border" value="1">
    <param name="Color" value="white">
    <embed id="LODOP_EM" TYPE="application/x-print-lodop" width=0 height=0 border=0 Color="white"
           PLUGINSPAGE="install_lodop.exe">
</object>
<script type="text/javascript">
    /**
     *  打印预览
     */
    //声明为全局变量
    var LODOP;
    function printTagByDetails(batchId, bkId, pbdId) {
        LODOP = getLodop(document.getElementById('LODOP'), document.getElementById('LODOP_EM'));
        LODOP.PRINT_INIT("打印");
        LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");
        var y = -1;
        var x = 0;

        $.ajax({
            type: "POST",
            url: "${ctx}/book/store/getStoresByBkId",
            data: {batch: batchId, bkId: bkId, pbdId: pbdId},
            dataType: "json",
            success: function (bookstores) {
                for (var i = 0; i < bookstores.length; i++) {
                    var store = bookstores[i];
                    if (i % 2 == 0) {
                        y++;
                        x = 0;
                    }
                    /*// 打印条形码
                     LODOP.ADD_PRINT_BARCODE(25 + y * 112, 34 + x * 370, 159, 50, "code39", store.banid);

                     var school = "<div style='background-color:#ffffff;font-size: 13px;text-align: center;'>" +
                     "<div style='height:20px;'>" + "图书馆" + "</div>" +
                     "</div>";
                     LODOP.ADD_PRINT_HTM(75 + y * 112, 34 + x * 370, 159, 25, school);
                     */
                    // 打印 索书号和分类
                    var bar = "<div style='background-color:#ffffff;font-size: 18px;text-align: center;'>" +
                            "<div style='height:25px;'>" + store.classcode + "</div>" +
                            "<div style='height:25px;'>" + store.place + "</div>" +
                            "<div style='height:16px;font-size: 13px;'>" + store.banid + "</div>" +
                            "</div>";
                    LODOP.ADD_PRINT_HTM(25 + y * 112, 34 + x * 185, 159, 70, bar);
                    x++;
                }
                LODOP.PRINT_DESIGN();
                LODOP.SHOW_CHART();
            }
        });
    }
</script>
</body>
</html>